﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreRay.IO;

namespace CoreRay
{
    public class CoreRayContext
    {
        private static CoreRayContext instance;

        public static CoreRayContext Current
        {
            get
            {
                if (instance == null)
                {
                    instance = new CoreRayContext();
                }

                return instance;
            }
        }

        private CoreRayContext()
        {
            this.ResourceManager = new ResourceManager();
            this.PluginManager = new PluginManager();
            this.LogManager = new LogManager();
            this.Statistics = new Statistics();
        }

        public ResourceManager ResourceManager
        {
            get;
            private set;
        }

        public Renderer Renderer
        {
            get;
            private set;
        }

        public RenderSettings RenderSettings
        {
            get;
            private set;
        }

        public PluginManager PluginManager
        {
            get;
            private set;
        }

        public LogManager LogManager
        {
            get;
            private set;
        }

        public Statistics Statistics
        {
            get;
            private set;
        }

        internal void AddRenderer(Renderer renderer, RenderSettings renderSettings)
        {
            if (this.Renderer == null)
            {
                this.Renderer = renderer;
                this.RenderSettings = renderSettings;

                this.PluginManager.ScanPluginsFolder();
            }

            else
            {
                throw new InvalidOperationException("A renderer has already been created.");
            }
        }
    }
}
